package com.ruoyi.notice.controller;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.notice.domain.Message;
import com.ruoyi.notice.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 消息中心Controller
 *
 * @author ruoyi
 * @date 2025-05-14
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;
    /**
     * 根据userId获取该用户的消息
     */
    @RequiresPermissions("notice:notice:list")
    @GetMapping("/getMessageByUserId")
    public AjaxResult getMessagesByUserId(@RequestParam("userId") Long userId) {
        System.out.println(userId);
        List<Message> messageList = messageService.getMessagesByUserId(userId);
        return AjaxResult.success(messageList);
    }

}
